<template>
  <div class="readBook">
      <!-- 在线阅读内容 -->
      <read-book-content @click="doClick" />
      <!-- 在线阅读底部 -->
      <read-book-footer class="d-none d-md-block" />
  </div>
</template>

<script>
  
  import ReadBookContent from './ReadBookComponents/ReadBookContent'
  import ReadBookFooter from './ReadBookComponents/ReadBookFooter'
  
  export default {
    name: 'ReadBook',
    components: {
      ReadBookContent,
      ReadBookFooter
    },
    data () {
      return {
        nowScroll: ''
      }
    },
    mounted() {
      
    },
    methods: {
      doClick() {
        alert(111);
        console.log('111');
      }
    },
    beforeRouteLeave(to, from, next) {
      // 离开当前路由时通过滚轮距离顶部的高度来设置书签
      if (document.body.scrollTop == 0) {
        this.nowScroll = document.documentElement.scrollTop;
      } 
      if (document.documentElement.scrollTop == 0) {
        this.nowScroll = document.body.scrollTop;
      }
      this.$store.dispatch('asynStorageBookMark', this.nowScroll);
      next();
    }
  }

</script>

<style scoped>
  *{margin: 0; padding: 0}
</style>